Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Nov 11, 2022

Context

From #1767 :

When the user picks an image from the device media library or took a picture from the device camera, we have to first save it in the app file system and then upload the image given the file URL. The image from the device media library or camera is of type PHAsset, and before we save it for future upload, we'd first export the raw PHAsset to an image with some optimization options.

Description

By updating the minimum release version to iOS 15 recently, we've seen some deprecation warnings. This PR fixes the case for uses of kUTTypeJPEG, kUTTypePNG, and kUTTypeGIF.

This PR does not deal with cases for UTTypeEqual, as it would seems the deprecation message is meant for Objective-C code?

'UTTypeEqual' was deprecated in iOS 15.0: Use -[UTType isEqual:] instead.

Changes

When returning or comparing different file extensions or file types, we change from using kUUType*, to UTType.* instead.

Testing instructions

I'm not 100% sure if I'm handling all test scenarios here, happy to get further feedback about it, but it should be good with the following:

  • Confirm that there's no issues uploading JPEG or GIF media types to a product
  • Tests should pass

@iamgabrielma iamgabrielma added the status: draft This is a draft, still need more work but can be reviewed and commented if asked. label Nov 11, 2022
@iamgabrielma iamgabrielma added this to the 11.3 milestone Nov 11, 2022
@iamgabrielma iamgabrielma added type: enhancement A request for an enhancement. iOS 15 Specific to iOS 15 labels Nov 11, 2022
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 11, 2022

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8093-71b42df on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@iamgabrielma iamgabrielma removed the status: draft This is a draft, still need more work but can be reviewed and commented if asked. label Nov 11, 2022
@iamgabrielma iamgabrielma requested a review from jaclync November 11, 2022 03:09
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the warnings in Yosemite tests! I think we can directly compare and use the identifier of any UTType as a string, left some non-blocking suggestions

Comment on lines 53 to 54
let gifTypeIdentifier = UTType.gif.identifier as CFString
if UTTypeEqual(resource.uniformTypeIdentifier as CFString, gifTypeIdentifier) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think comparing the identifier strings directly should be fine?

Suggested change
let gifTypeIdentifier = UTType.gif.identifier as CFString
if UTTypeEqual(resource.uniformTypeIdentifier as CFString, gifTypeIdentifier) {
if resource.uniformTypeIdentifier == UTType.gif.identifier {

Comment on lines 127 to 128
let gifTypeIdentifier = UTType.gif.identifier as CFString
guard UTTypeEqual(resource.uniformTypeIdentifier as CFString, gifTypeIdentifier) else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: similar to above, I think direct string comparison is fine?

Suggested change
let gifTypeIdentifier = UTType.gif.identifier as CFString
guard UTTypeEqual(resource.uniformTypeIdentifier as CFString, gifTypeIdentifier) else {
guard resource.uniformTypeIdentifier == UTType.gif.identifier else {

@iamgabrielma
Copy link
Contributor Author

Thanks for the review! Removed redundant typecasts here 6530b16 , and UTTypeEqual usage here 71b42df 🎉

@iamgabrielma iamgabrielma merged commit d3a39df into trunk Nov 14, 2022
@iamgabrielma iamgabrielma deleted the task/kUTType-deprecated-ios-15 branch November 14, 2022 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

iOS 15 Specific to iOS 15 type: enhancement A request for an enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants